package com.heima.admin.controller.v1;

import com.heima.admin.service.AdSensitiveService;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author lo
 */
@RestController
@Api(tags = "敏感词管理")
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {

    @Autowired
    private AdSensitiveService adSensitiveService;

    /**
     * 根据名称分页查询敏感词列表
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("分页查询敏感词列表")
    public ResponseResult getList(@RequestBody SensitiveDto sensitiveDto){
      return  adSensitiveService.sensitiveByPage(sensitiveDto);
    }

    /**
     * 删除敏感词信息
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    @ApiOperation("删除敏感词")
    public ResponseResult delSensitive(@PathVariable Integer id){
        return  adSensitiveService.delSensitive(id);
    }

    /**
     * 保存敏感词信息
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    @ApiOperation("保存敏感词")
    public ResponseResult saveSensitive(@RequestBody AdSensitive adSensitive ){
        return  adSensitiveService.saveSensitive(adSensitive);
    }

    /**
     * 修改敏感词信息
     * @param adSensitive 敏感词实体类
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("修改敏感词信息")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return  adSensitiveService.updateSensitive(adSensitive);
    }

    /**
     * 查询所有敏感词
     * @return ResponseResult封装的list
     */
    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return adSensitiveService.selectAllSensitives();
    }


}
